package univer.oko.table;


import javax.swing.*;
import javax.swing.table.DefaultTableColumnModel;

public class CDTable extends JTable {
    public CDTable(int columns, DefaultTableColumnModel cmodel, int editCol, boolean isOtherEditable) {
        super(new CDTableModel(columns, editCol, isOtherEditable), cmodel);
        this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        this.setRowHeight(19);
    }

    public CDTable(int columns, DefaultTableColumnModel cmodel, boolean isEditable) {
        super(new CDTableModel(columns, isEditable), cmodel);
        this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        this.setRowHeight(19);
    }

    public CDTableModel getTableModel() {
        return (CDTableModel) getModel();
    }

    public int addRow() {
        this.getTableModel().addRow();
        return this.getTableModel().getRowCount() - 1;
    }

    public void removeRow() {
        this.getTableModel().removeRow();
    }

    public void removeRow(int index) {
        this.getTableModel().removeRow(index);
    }
}
